<%--
  Created by IntelliJ IDEA.
  User: 33503
  Date: 2023/11/22
  Time: 17:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
    <!--引入jquery和bootstrap -->
    <script type="text/javascript" src="js/jquery-1.12.3.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body style="background-size:cover;background-repeat: no-repeat; background-image: url('image/login.png');">
<div style="background-color: #337ab7; color: white; width: 40%; height: 60%; float: right;
margin-right: 50px; margin-top: 150px;  border-radius: 10px">
    <div align="center" style="padding-top: 2em">
        <span style="font-size: 3em">用户登录</span>
        <div><a href="${ pageContext.request.contextPath }/register" style="color: whitesmoke">点击注册</a></div>
        ——————————————————————
        <form action="${ pageContext.request.contextPath }/login" method="POST" id="loginForm">
            <table style="padding-left: 1em; font-size: larger; color: white">
                <tr><td style="color: red" colspan="2">${msg}</td></tr>
                <tr>
                    <td>账&nbsp;&nbsp;&nbsp;号：</td>
                    <td><input type="text" name="username" id="username" placeholder="请输入账号" style="width: 180px; height: 36px" onkeyup="value=value.replace(/[^\d]/g,'')"
                               maxlength=9/>
                    </td>
                </tr>
                <tr>
                    <td>密&nbsp;&nbsp;&nbsp;码：</td>
                    <td><input type="password" name="password" id="password" placeholder="请输入密码" style="width: 180px; height: 36px"/>
                    </td>
                </tr>
            </table>
            <table style="padding-left: 0.6em;margin-top: 10px">
                <tr>
                    <td><input type="radio" name="sysType" value="manager" style="zoom: 1.5">管理员
                        <input type="radio" name="sysType" value="teacher" style="zoom: 1.5">教师
                        <input type="radio" name="sysType" value="student" checked style="zoom: 1.5">学生
                </tr>
                <tr>
                    <td><input type="button" value="登录" style="height: 30px; width: 60px; background-color: #2e6da4; border-color: #2e6da4; font-size: large; color: white; margin-right: 40px; margin-top: 20px" onclick="jianyan()"/>
                        <input type="reset" value="重置" style="height: 30px; width: 60px; background-color: #2e6da4; border-color: #2e6da4; font-size: large; color: white"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<script>
    function myTrim(x) {
        return x.replace(/^\s+|\s+$/gm,'');}
    function jianyan(){
        //提交form表单前判断
        var username=myTrim($("#username").val());//消除空格
        var password=myTrim($("#password").val());
        if(username===""||username==null){
            alert("账号不能为空");
            return;
        }else if(password===""||password==null){
            alert("密码不可为空");
            return;
        }else {
            //试题类型为单选题或多选题时，CD选项不可为空
            $("#loginForm").submit();
            return false;
        }
    }
</script>
</body>
</html>